#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void dfs(vector<vector<int>> &gh, vector<long> &size, vector<long> &num, int u, int p)
{
        for(auto v : gh[u]){
                if(v != p){
                        dfs(gh, size, num, v, u);
                        size[u] += size[v];
                        num[u] += num[v] + size[v];
                }
        }
}

void dp_deep(vector<vector<int>> &gh, vector<long> &size, vector<long> &num, vector<long> &dp, int u, int p, int n)
{
        for(auto v : gh[u]){
                if(v != p){
                        dp[v] = dp[u] - size[v] + n - size[v];
                        dp_deep(gh, size, num, dp, v, u, n);
                }
        }
}

int main()
{
        int n = 0;
        cin >> n;
        vector<vector<int>> gh(n + 1);
        
        for(int i = 0, u, v; i < n - 1; i++){
                cin >> u >> v;
                gh[u].push_back(v);
                gh[v].push_back(u);
        }

        vector<long> size(n + 1, 1), num(n + 1, 0);
        dfs(gh, size, num, 1, 0);

        vector<long> dp(n + 1, 0);
        dp[1] = num[1];
        dp_deep(gh, size, num, dp, 1, 0, n);
        cout << max_element(dp.begin(), dp.end()) - dp.begin() << endl;
        return 0;
}
